<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>一键开启关闭</title>

    <script src="js/jquery-2.2.1.min.js"></script>
    <!-- BOOTSTRAP STYLES-->
    <link href="assets/css/bootstrap.css" rel="stylesheet" />
    <script src="js/bootstrap.min.js"></script>
    <!-- FONTAWESOME STYLES-->
    <link href="assets/css/font-awesome.css" rel="stylesheet" />
    <!--CUSTOM BASIC STYLES-->
    <link href="assets/css/basic.css" rel="stylesheet" />
    <!--CUSTOM MAIN STYLES-->
    <link href="assets/css/custom.css" rel="stylesheet" />
    <!-- GOOGLE FONTS-->
    <link href='css/fontsCss.css' rel='stylesheet' type='text/css' />

    <!--<link href="css/recommend.css" rel="stylesheet" type="text/css">-->
    <link href="css/main.css" rel="stylesheet" type="text/css">
    <link href="css/switch.css" rel="stylesheet" type="text/css">

    <!--树列表-->
    <link rel="stylesheet" href="css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="js/jquery.ztree.core.js"></script>

    <script src="../website/maintain/maintain.js"></script>
    <script src="js/main.js"></script>
    <script src="js/utlities.js"></script>

</head>
<body>

<div id="wrapper">

    <!-- /. NAV TOP  -->

    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div class="page-inner">
            <div>
                <div class="col-md-12">
                    <h4 class="page-head-line">一键开启关闭</h4>
                </div>
            </div>
            <div>
            </div>
            <!-- /. ROW  -->
            <div id="content">
                <div style="width: 100%;margin-top: 20%" align="center">
                    <a class="button-open openBtn" id="switch">开启</a>
                </div>
                <!--<a class="button-close closeBtn">关闭</a>-->
            </div>
            <!-- /. ROW  -->

        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
    <!--提示弹窗-->
    <div class="modal fade" id="infomodal" role="dialog" aria-labelledby="mypackage" aria-hidden="true">
        <div class="modal-dialog" style="width: 260px;">
            <div class="modal-content">
                <div class="modal-header" style="background: #F8F8F8;border-bottom: none">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="color: black;">x</button>
                    <h5 class="modal-title" style="color:#333;">信息</h5>
                </div>
                <div class="modal-body">
                    <div style="font-family: 微软雅黑;" id="info"></div>
                    <div align="right">
                        <a class="button-a opBtn" style="margin-top: 20px;" id="modal_confirm">确定</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function(){
        var switchObj = document.getElementById("switch");
        setTimeout(function(){
            if(maintainFlag==false){
                switchObj.innerHTML = "开启";
                switchObj.className = "button-open openBtn"
            }else{
                switchObj.innerHTML = "关闭";
                switchObj.className = "button-close closeBtn"
            }
        },100);

        $("#switch").click(function(){
            var sw = maintainFlag;
            if(switchObj.innerHTML == "开启"){
                sw = true;
                $.ajax({
                    url : urladdr + "/web/maintain",
                    method : "POST",
                    data : {
                        flag:sw,
                        token:Mytoken
                    },
                    success : function(data){
                        if(data.code == 0){
                            switchObj.innerHTML = "关闭";
                            switchObj.className = "button-close closeBtn";
                            modalinfo("开启成功");
                        }else if(data.code == 401){
                            location.href = "index.html"
                        }else{
                            modalinfo(data.msg);
                        }
                    }
                });
            }else{
                sw = false;
                $.ajax({
                    url : urladdr + "/web/maintain",
                    method : "POST",
                    data : {
                        flag:sw,
                        token:Mytoken
                    },
                    success : function(data){
                        if(data.code == 0){
                            switchObj.innerHTML = "开启";
                            switchObj.className = "button-open openBtn";
                            modalinfo("关闭成功");
                        }else if(data.code == 401){
                            location.href = "index.html"
                        }else{
                            modalinfo(data.msg);
                        }
                    }
                });
            }
        });
    });
</script>
<!-- /. WRAPPER  -->
</body>
</html>
